//未走访/走访操作控制
function onActionRendererZf(e) {
    var level = e.value;
    var s = "";
    if (level == '03') {
        s += '&nbsp;<a class="mini-button mini-button-primary"  onclick="toSuccourTabs()">&nbsp;&nbsp;走访&nbsp;&nbsp;</a>&nbsp';
    }
    s += '&nbsp;<a class="mini-button mini-button-info"  onclick="toViewHjqc()">&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp';
    return s;
}

// 安置帮教管理--帮教对象走访管理--走访管理.js
function toSuccourTabs() {
    var row = grid.getSelected();
    $.ajax({
        url: "/azbj/inmates/getHasDate?priNum=" + row.priNum,
        type: "GET",
        async: false,
        success: function (result) {
            if (result == "no") {
                mini.alert("请补录该服刑人员的刑期起止日");
            } else {
                mini.open({
                    //targetWindow: window,
                    url: "/azbj/azbjgl/view/toAddZfInfoTab?priNum=" + row.priNum,
                    title: "走访",
                    width: "60%",
                    height: "80%",
                    allowDrag: true,
                    allowResize: false,
                    showCloseButton: true,
                    onload: function () {
                    },
                    ondestroy: function (action) {
                        grid.reload();
                    }
                });
            }
        }
    })
}

//查看
function toViewHjqc() {
    var row = grid.getSelected();
    mini.open({
        url: "/azbj/bjdxInfo/hjqc/toViewTabs/view?priNum=" + row.priNum,
        title: "查看",
        width: "60%",
        height: "80%",
        allowDrag: true,
        allowResize: false,
        showCloseButton: true,
        onload: function () {
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}

// searchMap
function pldc(templateId, type) {
    var num = grid.getData().length;
    var flag = false;
    if (num <= 100) {
        flag = true;
    } else {
        // 导出信息超过100条则直接返回
        mini.alert("最多选择100条档案信息!");
        return;
    }
    if (flag && num > 0) {
        var rows = grid.getSelecteds();
        //如果勾选，导出勾选的数据
        if (rows.length > 0) {
            var idArr = [];
            for (i = 0; i < rows.length; i++) {
                var id = rows[i].priNum;
                idArr.push(id);
            }
            var ids = idArr.join(',');
            window.location.href = encodeURI("/azbj/azbjgl/dcda/exportData?priNum=" + ids + "&templateId=" + templateId + "&type=" + type);
            grid.reload();
        } else {
            //没有勾选导出全部数据
            if (flag) {
                mini.confirm("确定导出全部数据吗？", "数据导出",
                    function (action) {
                        if (action == "ok") {
                            if (num > 0) {
                                var rows = grid.getData();
                                var idArr = [];
                                for (i = 0; i < rows.length; i++) {
                                    var id = rows[i].priNum;
                                    idArr.push(id);
                                }
                                var ids = idArr.join(',');
                                window.location.href = encodeURI("/azbj/azbjgl/dcda/exportData?priNum=" + ids + "&templateId=" + templateId + "&type=" + type);
                                grid.reload();
                            }
                        }
                    }
                );
            }
        }
    } else {
        mini.alert("没有数据可导出!");
    }
}